-
Notifications
You must be signed in to change notification settings - Fork 1
Allow extra properties #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Quick vibe code to close vsoch#6
129398e to
2852d54
Compare
|
Testing in openPMD/openPMD-api#1826 |
vsoch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Some questions and comments.
| # Use empty schema {} which allows any type | ||
| for prop in allowed_props: | ||
| if prop not in schema['properties']: | ||
| schema['properties'][prop] = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the property is nested? And where is the full definition of the property?
| allowed_props = [prop.strip() for prop in allowed_props_str.split(',') if prop.strip()] | ||
| if not allowed_props: | ||
| print('❌ ERROR: No valid property names found in allowed_extra_properties', file=sys.stderr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just do sys.exit("Message") and it will exit with error and print the message.
| try: | ||
| schema_path = os.environ['SCHEMA_PATH_ESC'] | ||
| final_schema_path = os.environ['FINAL_SCHEMA_PATH_ESC'] | ||
| allowed_props_str = os.environ['ALLOWED_PROPS_ESC'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: variable names should not have types.
| | :--- | :--- | :--- | | ||
| | `path` 📍 | Where is your `.zenodo.json`? | `.zenodo.json` | | ||
| | `error_format` 🎨 | `text`, `json`, or `pretty-json` | `text` | | ||
| | `allowed_extra_properties` ✨ | Comma-separated list of extra property names to allow (e.g., `pub_id,custom_field`) | `''` (empty) | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just extra_properties ? I think allowed is implied.
|
|
||
| ### 🔓 Allowing Extra Properties | ||
|
|
||
| Some Invenio instances (like [RODARE](https://rodare.hzdr.de)) require additional properties beyond the standard Zenodo schema. You can explicitly allow these properties using the `allowed_extra_properties` input: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if something is allowed and required? Or requires more than just being in the listing? Notably, we are adding the allowed extra properties, but not defining types, etc.
| FINAL_SCHEMA_PATH="/tmp/modified_schema.json" | ||
|
|
||
| # Use Python to modify the schema and add allowed extra properties | ||
| if ! SCHEMA_PATH_ESC="$SCHEMA_PATH" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this block let's:
- Write an actual Python script with argparse
- Run the command here, providing the environment variables
It will be more understandable for the reader developer than as currently done.
| import os | ||
| import sys | ||
| try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LLMs have a tendency to wrap everything in try/except. My preference would be to not do that. We aren't catching any specific error here, especially with the various checks. If there is an error I want it to raise and see it and don't need the additional wrapping.
| if prop not in schema['properties']: | ||
| schema['properties'][prop] = {} | ||
| # Write the modified schema |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure that comments are useful/meaningful.
Quick vibe code to close #6